﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ledict.ConditionExtract.BLL.WorkProcess;
using Ledict.ConditionExtract.Common;
using Ledict.ConditionExtract.Model;
using Ledict.ConditionExtract.DAL;
namespace Ledict.ConditionExtract.BLL
{

    public class DataProcess_EditNode
    {

        Express_MatchSituationBLL express_matchsituationbll = new Express_MatchSituationBLL();
        WorkThread_Public work = new WorkThread_Public();
        public string AddNode(string CC_ID, string pid, SYS_Express_MatchSituation NewModel)
        {
           
            SYS_Express_MatchSituation PidModel = new SYS_Express_MatchSituation();//父级节点信息
            PidModel = express_matchsituationbll.GetMatchSituation(pid);
            if (PidModel != null)//是否match表数据
            {
                if (PidModel.SituationName == "组合")//添加第一级节点
                {
                    NewModel.ParentID = PidModel.CauseGroupID.Substring(1,PidModel.CauseGroupID.Length-1);
                    NewModel.AllStituationIDs = CC_ID;
                    NewModel.CauseGroupID = PidModel.CauseGroupID;
                    NewModel.AllParentID = "";
                }
                else//添加非第一级
                {
                    NewModel.ParentID = PidModel.MS_ID;
                    NewModel.AllStituationIDs = PidModel.AllStituationIDs + "," + CC_ID;
                    NewModel.CauseGroupID = PidModel.CauseGroupID;
                    NewModel.AllParentID = PidModel.AllParentID;
                }
                return work.AddMatch(CC_ID, NewModel.ParentID, NewModel.AllStituationIDs, NewModel.CauseGroupID, NewModel, NewModel.AllParentID, true);//添加
            }
            return "";
        }
    }
}
